package com.itheima.mapper;

import com.itheima.pojo.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper//1.创建接口的代理对象  2.将代理对象放入IOC容器
public interface DeptMapper {
    //    @Select("select * from dept")
    //根据时间降序
    @Select("select * from dept order by update_time desc")
    List<Dept> list();

    //在之前的方法中。进行事务，需要的操作
    @Delete("delete from dept where id=#{id}")
    void deleteById(Integer id);

    @Insert("insert into dept (name, create_time, update_time) values (#{name},#{createTime},#{updateTime})")
    void add(Dept dept);


    @Select("select * from dept where id=#{id}")
    Dept getById(Integer id);

    @Update("update dept set name=#{name},update_time=#{updateTime} where id=#{id}")
    void updateById(Dept dept);
}
